package com.xiyu.service.repository.setting.global;

import com.xiyu.service.model.setting.global.SettingGlobal;
import com.xiyu.service.model.setting.global.SettingGlobalTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.Optional;
import java.util.List;

public interface SettingGlobalRepository extends JRepository<SettingGlobal, Long> {
    SettingGlobalTable settingGlobalTable = SettingGlobalTable.$;

    default void updateSetting(String settingKey, String settingValue){
        sql().createUpdate(settingGlobalTable)
                .where(settingGlobalTable.settingKey().eq(settingKey))
                .set(settingGlobalTable.settingValue(), settingValue)
                .execute();
    }

    Optional<SettingGlobal> findBySettingKey(String settingKey);

    List<SettingGlobal> findBySettingClass(String settingClass);


}